<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</head>
<body>
<table class="table">
    <thead>
    <tr>
        <th>商品id</th>
        <th>商品名称</th>
        <th>商品价格</th>
        <th>市场价</th>
        <th>成本价</th>
        <th>商品库存</th>
        <th>商品简单描述</th>
        <th>详细介绍</th>
        <th>商品logo图</th>
        <th>品牌</th>
        <th>商品重量</th>
        <th>商品体积</th>
        <th>商品关键词</th>
        <th>上架</th>
        <th>包邮</th>
        <th>推荐</th>
        <th>新品</th>
        <th>热卖</th>
        <th>供货商</th>
    </tr>
    </thead>
    <tbody>
    @foreach($data as $item)
        <tr>
            <td>{{$item['id']}}</td>
            <td>{{$item['goods_name']}}</td>
            <td>{{$item['goods_price']}}</td>
            <td>{{$item['market_price']}}</td>
            <td>{{$item['cost_price']}}</td>
            <td>{{$item['goods_number']}}</td>
            <td>{{$item['goods_remark']}}</td>
            <td>{{$item['goods_desc']}}</td>
            <td>
                <img src="{{$item['goods_logo']}}" width="100px" height="50px" >
            </td>
            <td>{{$item['brand_id']}}</td>
{{--            <td>{{$item['mould_id']}}</td>--}}
            <td>{{$item['weight']}}</td>
            <td>{{$item['volume']}}</td>
            <td>{{$item['keywords']}}</td>
            <td>
                @if( $item['is_on_sale']==1)
                  <span  onclick="change(this,{{$item['id']}})" >是 </span>
                @else
                  <span  onclick="change(this,{{$item['id']}})" >否</span>
                @endif
            </td>
            <td>
                @if( $item['is_free_shipping']==1)
                    是
                @else
                    否
                @endif
            </td>
            <td>
                @if( $item['is_recommend']==1)
                    是
                @else
                    否
                @endif
            </td>
            <td>
                @if( $item['is_new']==1)
                    是
                @else
                    否
                @endif
            </td>
            <td>
                @if( $item['is_hot']==1)
                    是
                @else
                    否
                @endif
            </td>
            <td>
               {{$item['suppliers_id']}}
            </td>
        </tr>
    @endforeach
    </tbody>
</table>
{{$data->links()}}
</body>
</html>
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/ueditor/ueditor.config.js"></script>
<script src="/ueditor/ueditor.all.js"></script>
<script>
  function change(obj,id){
      var url="{{route('shop.change')}}";
      let is_on_sale=$(obj).attr("is_on_sale");
      if(is_on_sale===0){
          is_on_sale===1;
      }else {
          is_on_sale===0;
      }
      $.get(url,{
          id,is_on_sale
      }).then(ret=>{
          if(is_on_sale===0){
              $(obj).removeClass('label-success').addClass('label-defalut').html('是');
          }else{
              $(obj).removeClass('label-defalut').addClass('label-success').html('否');
          }
      })
  }
</script>


